<?php

class m190318_125823_event_init extends yii\db\Migration {

    const EVENT_TABLE_NAME = '{{%event}}';
    const EVENT_LOG_TABLE_NAME = '{{%event_log}}';

    public function up() {
        $this->createTable(self::EVENT_TABLE_NAME, [
            'id' => $this->primaryKey(),
            'name' => $this->string(64)->notNull(),
            'type' => $this->integer(),
            'description' => $this->string()->notNull(),
            'valid' => $this->integer()->notNull(),
            'visible' => $this->boolean()->notNull(),
        ]);

        $this->createTable(self::EVENT_LOG_TABLE_NAME, [
            'id' => $this->primaryKey(),
            'uid' => $this->integer(11)->notNull()->defaultValue(0),
            'eventid' => $this->integer(11)->notNull()->defaultValue(0),
            'type' => $this->integer()->notNull()->defaultValue(0),
            'object' => $this->string(128)->notNull(),
            'objectid' => $this->integer(11)->notNull()->defaultValue(''),
            'datatype' => $this->integer(1)->notNull()->defaultValue(0),
            'data' => $this->text(),
            'status' => $this->integer(1)->notNull()->defaultValue(0),
            'ctime' => $this->integer(10)->notNull()->defaultValue(0),
            'cuser' => $this->integer(10)->notNull()->defaultValue(0),
            'mtime' => $this->integer(10)->notNull()->defaultValue(0),
            'muser' => $this->integer(10)->notNull()->defaultValue(0),
        ]);
    }

    public function down() {
        $this->dropTable(self::EVENT_TABLE_NAME);
        $this->dropTable(self::EVENT_LOG_TABLE_NAME);
    }

}
